package com.tianqu.tms.www.proxymember.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Codes;
import com.tianqu.tms.entity.Vendor;
import com.tianqu.tms.www.proxymember.viewhelper.ProxyMemberCarSearchInputViewHelper;

/**
 * @author zhangxueliang
 * 待办车辆信息修改录入action
 */
public class ProxyMemberCarUpdateInputAction extends TmsAction{
	private Logger logger = Logger
	.getLogger(ProxyMemberCarUpdateInputAction.class);
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		Codes code = Codes.getInstance();
		ProxyMemberCarSearchInputViewHelper viewhelper = 
			(ProxyMemberCarSearchInputViewHelper)uc.getAttribute(TmsConstants.VIEWHELP);
		
		viewhelper.setCarTypeList(code
				.getCodeslistByItemId(Codes.VEHICLE_TYPE));// 车辆类型
		viewhelper.setColorList(code
				.getCodeslistByItemId(Codes.VEHICLE_COLOR));// 车辆颜色
		viewhelper.setCarUseList(code
				.getCodeslistByItemId(Codes.USER_NATURE));// 使用性质list
		viewhelper.setCardTypeList(code
				.getCodeslistByItemId(Codes.PLATE_TYPE));// 号牌种类list
		viewhelper.setFuelTypeList(code
				.getCodeslistByItemId(Codes.FUEL_TYPE));// 燃料种类list
		viewhelper.setCountryStyleList(code
				.getCodeslistByItemId(Codes.VEHICLE_COUNTRY));// 国别list
		viewhelper.setAttributeList(code
				.getCodeslistByItemId(Codes.ATTACHMENT_PROPERTY));// 车辆状态list'
		viewhelper.setOwnerTypeList(code
				.getCodeslistByItemId(Codes.CAR_OWNER));// 车主类型list
		viewhelper.setGearBoxList(code.getCodeslistByItemId(Codes.GEARBOX_TYPE));//变速箱类型list
		
		// 车辆品牌
		Vendor vendor = Vendor.getInstance();
		viewhelper
				.setVendorList(vendor.findAllVendorInfo());
		viewhelper.setCardType(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.PLATE_TYPE, viewhelper.getCardType())));		
		viewhelper.setCarType(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.VEHICLE_TYPE,viewhelper.getCarType())));
		viewhelper.setCarUse(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.USER_NATURE,viewhelper.getCarUse())));
		viewhelper.setColor(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.VEHICLE_COLOR,viewhelper.getColor())));
		viewhelper.setCountryStyle(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.VEHICLE_COUNTRY,viewhelper.getCountryStyle())));
		
		
		viewhelper.setGearbox(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.GEARBOX_TYPE,viewhelper.getGearbox())));
		viewhelper.setFuelType(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.FUEL_TYPE,viewhelper.getFuelType())));
		viewhelper.setOwnerType(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.CAR_OWNER,viewhelper.getOwnerType())));
		viewhelper.setStatus(String.valueOf(code.getItemCodeByItemIdAndItemValue(Codes.PROXYCAR_STATUS,viewhelper.getStatus())));
		
		request.setAttribute(VIEWHELP, viewhelper);
		
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
